<?php

class Ticket {

    public $idTicket;
    public $url;
    public $totalPrice;
    public $operatingCarrier;
    public $ticketFee;
    public $priceAdult;
    public $inboundStops;
    public $outboundStops;
    public $journeyTime;
    public $filter;
    //Array of incoming and outgoing flights
    //Including stops
    //Outbounds = Heenreis
    //return = Terugreis
    //Every flight get stored in the flights array
    //Flight holds the flight data

    public $flights_outbound = array();
    public $flights_inbound = array();

    public function Ticket($id, $url, $totalPrice, $priceAdult, $operatingCarrier, $ticketFee, $outboundStops, $journeyTime) {
        $this->idTicket = $id;
        $this->url = $url;
        $this->priceAdult = $priceAdult;
        $this->totalPrice = $totalPrice;
        $this->operatingCarrier = $operatingCarrier;
        $this->ticketFee = $ticketFee;

        $this->outboundStops = $outboundStops;
        $this->journeyTime = $journeyTime;

        //Alle filters op true zetten als startwaarde
        $this->filter = array(
            "stop" => true,
            "carrier" => true,
            "timeArrival" => true,
            "travelTime" => true);
    }

    public function setFlightInbound($fromIATA, $toIATA, $fromDateTime, $toDateTime, $carrier, $flightTime, $flightNumber) {
        $flightInbound = $this->createFlightArray($fromIATA, $toIATA, $fromDateTime, $toDateTime, $carrier, $flightTime, $flightNumber);
        array_push($this->flights_inbound, $flightInbound);
        $this->inboundStops = count($this->flights_inbound);
    }

    public function setFlightOutbound($fromIATA, $toIATA, $fromDateTime, $toDateTime, $carrier, $flightTime, $flightNumber) {
        $flightOutbound = $this->createFlightArray($fromIATA, $toIATA, $fromDateTime, $toDateTime, $carrier, $flightTime, $flightNumber);
        array_push($this->flights_outbound, $flightOutbound);
    }

    private function createFlightArray($fromIATA, $toIATA, $fromDateTime, $toDateTime, $carrier, $flightTime, $flightNumber) {
        $flight = array(
            "fromIATA" => $fromIATA,
            "toIATA" => $toIATA,
            "fromDateTime" => $fromDateTime,
            "toDateTime" => $toDateTime,
            "carrier" => $carrier,
            "flightTime" => $flightTime,
            "flightNumber" => $flightNumber
        );
        return $flight;
    }

}